import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class demo18 {
    public static void main(String[] args) throws FileNotFoundException {
        //使用try with resource 来打开文件 关闭文件, 这个是自动帮组打开关闭文件的, 避免忘记或者提前return
        try (FileInputStream fileInputStream = new FileInputStream("test.txt")) {
            while (true) {
                byte[] bytes = new byte[1000];//数组有多大, 一次性就读几个字节
                int read = fileInputStream.read();
                //记录当前这次读的流对象中有多少
                System.out.println("读取到的read: "+read);
                if (read == -1) {
                    break;
                }
                System.out.printf("%c", read);
              /*  for (int i = 0; i < read; i++) {
                    System.out.printf("0x%x\n", bytes[i]);
                }*/
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }

}
